﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data;

namespace T7practice1
{
    public partial class Form1 : Form
    {
        DataTable dt = new DataTable();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select * from Gamelist";
            dt = DBHelper.Select(sql);
            dataGridView1.DataSource = dt;
        }

        private void BtSearch_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.RowFilter = string.Format("GameName like '%{0}%'", TxtSearch.Text);
            dataGridView1.DataSource = dv;
        }

        private void BtUp_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = "GamePrice";
            dataGridView1.DataSource = dv;
        }

        private void BtDown_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = "GamePrice desc";
            dataGridView1.DataSource = dv;
        }

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }
    }
}
